package com.rovinj_server.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;


import com.rovinj_server.R;
import com.rovinj_server.entity.InventorySub;
import com.rovinj_server.entity.InventorySub;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by LiuLiu on 2017/2/26.
 */

public class InventorysScanningAdapter extends RecyclerView.Adapter<InventorysScanningAdapter.VH> {


    private List<InventorySub> mList = new ArrayList<>();

    public InventorysScanningAdapter(List<InventorySub> data) {
        this.mList = data;
    }

    @Override
    public VH onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_task_scanning, parent, false);

        return new VH(view);
    }


    @Override
    public void onBindViewHolder(VH holder, int position) {
        InventorySub inventorySub = mList.get(position);
        holder.goods.setText(inventorySub.getLocation());
        holder.barod.setText(inventorySub.getBarode());
        holder.code.setText(inventorySub.getCode());

        holder.maitype.setText(inventorySub.getMaitype());
        holder.Sjnumber.setText(inventorySub.getSjnumber());
        holder.discNumber.setText(inventorySub.getDiscNumber() + "");

    }

    @Override
    public int getItemCount() {
        return mList == null ? 0 : mList.size();
    }

    public List<InventorySub> getList() {
        return mList;
    }

    public void setList(List<InventorySub> list) {
        mList = list;
    }


    static class VH extends RecyclerView.ViewHolder {
        public TextView goods; //库位
        public TextView barod; //条码
        public TextView code; //商品
        public TextView type; //旧款号
        public TextView maitype; //品名
        public TextView sizeName; //颜色
        public TextView diffNumber;
        public TextView Sjnumber;
        public TextView discNumber;

        public VH(View itemView) {
            super(itemView);
            AutoUtils.autoSize(itemView);
            goods = (TextView) itemView.findViewById(R.id.goods);
            barod = (TextView) itemView.findViewById(R.id.barode);
            code = (TextView) itemView.findViewById(R.id.code);
            type = (TextView) itemView.findViewById(R.id.type);
            maitype = (TextView) itemView.findViewById(R.id.maitype);
            sizeName = (TextView) itemView.findViewById(R.id.sizeName);
            Sjnumber = (TextView) itemView.findViewById(R.id.Sjnumber);
            discNumber = (TextView) itemView.findViewById(R.id.discNumber);
        }
    }
}
